﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;
// Based off CDC's Epi Info 7 derived QueryParameter class; see http://epiinfo.codeplex.com

namespace NutriStat.Data
{
    public class QueryParameter : IDbDataParameter 
	{
		#region Private Members
		private int size;
		private byte scale;
		private byte precision;
		private DbType dbType;
		private ParameterDirection direction;
		private bool isNullable;
		private string parameterName = string.Empty;
		private string sourceColumn = string.Empty;
		private DataRowVersion sourceVersion;
		private object parameterValue;
		#endregion

		#region Constructors		
		private QueryParameter()
		{
		}
		
		public QueryParameter(string paramName, DbType paramType, object paramValue)
		{
			this.ParameterName = paramName;
			this.DbType = paramType;
			this.Value = paramValue;
			this.Direction = ParameterDirection.Input;
			this.SourceVersion = DataRowVersion.Default;
		}
        
		public QueryParameter(string paramName, DbType paramType, object paramValue, string sourceCol)
		{
			this.ParameterName = paramName;
			this.DbType = paramType;
			this.Value =  paramValue;
			this.Direction = ParameterDirection.Input;
			this.SourceColumn = sourceCol;
			this.SourceVersion = DataRowVersion.Default;			
		}
		#endregion

		#region Public Properties
		public int Size
		{
			get
			{
				return this.size;
			}
			set
			{
				this.size = value;
			}
		}		

		public byte Scale
		{
			get
			{
				return this.scale;
			}
			set
			{
				this.scale = value;
			}
		}

		public byte Precision
		{
			get
			{
				return this.precision;
			}
			set
			{
				this.precision = value;
			}
		}

		public System.Data.DbType DbType
		{
			get
			{
				return this.dbType;
			}
			set
			{
				this.dbType = value;
			}
		}
		
		public ParameterDirection Direction
		{
			get
			{
				return this.direction;
			}
			set
			{
				this.direction = value;
			}
		}
		
		public bool IsNullable
		{
			get
			{
				return this.isNullable;
			}
			set
			{
				this.isNullable = value;
			}
		}
		
		public string ParameterName
		{
			get
			{
				return this.parameterName;
			}
			set
			{
				this.parameterName = value;
			}
		}
		
		public string SourceColumn
		{
			get
			{
				return this.sourceColumn;
			}
			set
			{
				this.sourceColumn = value;
			}
		}
		
		public DataRowVersion SourceVersion
		{
			get
			{
				return this.sourceVersion;
			}
			set
			{
				this.sourceVersion = value;
			}
		}
		
		public object Value
		{
			get
			{
				return this.parameterValue;
			}
			set
			{
				this.parameterValue = value;
			}
		}

		#endregion
    }
}
